<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="css/common.css">
  <link rel="stylesheet" href="css/login.css">
</head>
<body>
<div class="nav">
  <img src="image/头像.jpg" alt="头像">
  <span class="title1">我的博客系统</span>
  <a href="home.html">主页</a>
  <a href="personlist.html">我的</a>
  <a href="edit.html">创作</a>
  <a href="register.html">注册</a>
</div>
<div id="one">
  <div class="login">
    <div class="text">登录</div>
    <div class="one"><span class="name">用户名</span><input type="text" class="user"></div>
    <div class="one"><span class="name">密码</span><input type="password" class="password"></div>
    <div class="submit"><input type="submit" class="button" value="登 录"></div>
  </div>
</div>

<script src="js/jquery.min.js"></script>
<script>
        let submit = document.querySelector('.submit');
        submit.onclick = function() {
            let username = document.querySelector('.user');
            let password = document.querySelector('.password');
            if(username.value.trim() == ""){
                alert("请输入用户名!");
                username.focus();
                return;
            }
            if(password.value.trim() == ""){
                alert("请输入密码!");
                password.focus();
                return;
            }
            $.ajax({
                url: "save",
                method: "post",
                data: JSON.stringify({username: username.value.trim(), password: password.value.trim()}),
                contentType: "application/json;charset=utf-8",
                success: function(data,status) {
                    console(data.message)
                    console(data.data.message);
<!--                    if (data.message == null){-->
<!--                        location.assign("home.html");-->
<!--                    } else {-->
<!--                        username.value="";-->
<!--                        password.value="";-->
<!--                        alert(data.message);-->
<!--                    }-->
                }
            })
        }
    </script>
</body>
</html>